package metadata;

import java.sql.DriverManager;

import options.Options;

import com.mysql.jdbc.Connection;
import java.sql.*; 

public class DB {
	
	public static Connection connect(Options conf){
		Connection conn = null;
		    String url = conf.get("URL");
		    String dbName = conf.get("DBNAME");
		    String driver = conf.get("DRIVER");
		    String userName = conf.get("USER"); 
		    String password = conf.get("PASSWORD");
		    
		    try {
		      Class.forName(driver).newInstance();
		      conn = (Connection) DriverManager.getConnection(url+dbName,userName,password);
		      System.err.println("Connected to the database");
		    } catch (Exception e) {
		      e.printStackTrace();
		    }
		    return conn;
	}	
}
